//index.js
//获取应用实例
import chartWrap from '../../canvas/chartWrap'
import getConfig from './getConfig'
var app = getApp()
Page({
    data: {
      titil:'月温度趋势',
      
    },
    onLoad: function () {

      var pageThis = this;
      var labels = [];
      var data = [];
      wx.request({
        url: "https://xuzhenglucky.com.cn/getTemData",
        data: {},
        header: {
          "Content-Type": "application/json"
        },
        success: function (res) {
          console.log(res);
           var resdata = res.data;
          // var JSON_OBJ = JSON.parse(data);
           console.log(resdata);
          
           labels = resdata.label;
           data = resdata.data;
           console.log(labels);
           console.log(data);
           
           let width = 320;
           let canvasConfig = {
             width: width,
             height: width * 0.45,
             id: 'myCanvas'
           }
           console.log(labels);
           console.log(data);
           let config = getConfig(canvasConfig, labels, data);
           chartWrap.bind(pageThis)(config);

        
        },
        fail: function (err) {
          console.log(err)
        }

      });

      

      
      
      // try {
      //   let res = wx.getSystemInfo();
        
      //   width = res.windowWidth;
      // } catch (e) {
      //   console.error('getSystemInfo failed!');
        
      // }
      //var list = ['myCanvas', 'myCanvas2', 'myCanvas3']
     // for (var i = 0; i < this.data.list.length;i++){
        
 

     //}
      
    },
    onShow: function () {
   
    }
})
